package shake.jsf;

import javax.faces.application.NavigationHandler;
import javax.faces.context.FacesContext;

import shake.navigation.Pages;
import shake.servlet.ShakeServletContext;

public class ShakeNavigationHandler extends NavigationHandler {
	NavigationHandler delegate;

	public ShakeNavigationHandler(NavigationHandler delegate) {
		this.delegate = delegate;
	}

	@Override
	public void handleNavigation(FacesContext context, String fromAction,
			String outcome) {
		if (ShakeServletContext.getInjector().getInstance(Pages.class).handle(
				fromAction, outcome)) {
			return;
		} else {
			delegate.handleNavigation(context, fromAction, outcome);
		}
	}

}
